<template>
	<view class="container">
		<u-toast ref="uToast" />
		<u-navbar :is-back="true" title="受理页面" back-icon-color='#333333' height="50" :border-bottom="false">
		</u-navbar>
		<view class="list">
			<view class="repair_number">
				<text>报修编号:</text>
				<text>{{maintenance_id}}</text>
			</view>
			<view class="category">
				<text>类别</text>
				<text>{{maintenance_type}}</text>
			</view>
			<view class="matter">
				<text>内容</text>
				<text>{{maintenance_content}}</text>
			</view>
			<view class="location">
				<text>位置</text>
				<text>{{maintenance_address}}</text>
			</view>
			<view class="applicant">
				<text>申请人</text>
				<text>{{maintenance_name}}</text>
			</view>
			<view class="remarks">
				<text>申请人备注</text>
				<text>{{maintenance_remark}}</text>
			</view>
			<view class="accessory">
				<text>附件</text>
			</view>
			<!-- <view class="picture">
				<image src="../../static/tupian101.png" mode="widthFix"></image>
				<image src="../../static/tupian101.png" mode="widthFix"></image>
			</view> -->
			<view class="" style="width:710rpx; height:30rpx; margin-left:20rpx; border-bottom: 1rpx solid #F2F2F2;">
			</view>
			<view class="submit">
				<text>提交时间</text>
				<text>{{maintenance_time}}</text>
			</view>
			<view class="results">
				<text>受理结果</text>
				<text @click="changeStatus(0)" :style="{background:leftBgColor,color:leftColor}">等待处理</text>
				<text @click="changeStatus(1)" :style="{background:centerBgColor,color:centerColor}">已同意</text>
				<text @click="changeStatus(2)" :style="{background:rightBgColor,color:rightColor}">已拒绝</text>
			</view>
			<view class="receiver">
				<text>受理人备注</text>
			</view>
			<view class=""
				style="width:710rpx; height:15rpx; margin-left:20rpx; background:#F2F2F2; border-top-left-radius:12rpx; border-top-right-radius:12rpx;">

			</view>
			<textarea value="" v-model="form.handle_remark" placeholder="单行输入"
				style="width:710rpx; height:160rpx; margin-left:20rpx; background:#F2F2F2; text-indent:1em; border-bottom-left-radius:12rpx; border-bottom-right-radius:12rpx;" />
			<view class="" style="width:100%; height:25rpx;background:#fff;">

			</view>
		</view>
		<view class="confirm">
			<view class="verify" @click="repairApply">
				{{verify}}
			</view>
		</view>
	</view>
</template>

<script>
	import request from '../../request.js'
	import time from '../../time.js'
	export default {
		data() {
			return {
				dataList: [],
				input_content: '',
				verify: '确认',
				maintenance_type: '',
				maintenance_id: '',
				maintenance_content: '',
				maintenance_address: '',
				maintenance_name: '',
				maintenance_remark: '',
				maintenance_time: '',
				maintenance_status: '',
				maintenance_person: '',
				leftBgColor: '#FFA100',
				leftColor: '#fff',
				centerBgColor: '#EEEEEE',
				centerColor: '#333333',
				rightBgColor: '#EEEEEE',
				rightColor: '#333333',
				process_time: '',
				maintenance_note: '',
				repair_id: '',
				form: {
					status: 1,
					handle_remark: '',
					repair_id: '',
				}
			}
		},
		onLoad(option) {
			if (option.id) {
				this.repair_id = option.id;
			}
			this.repairInfo();
		},
		methods: {
			repairInfo() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				this.display = false;
				let _this = this;
				request({
					url: base_url + 'teacher/repair/repairInfo',
					method: 'post',
					data: {
						repair_id: this.repair_id ? this.repair_id : 1,
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.maintenance_id = res.data.data.repair_id;
							_this.form.repair_id = res.data.data.repair_id;
							_this.maintenance_remark = res.data.data.remark;
							_this.maintenance_time = time.format(res.data.data.create_time);
							_this.maintenance_address = res.data.data.room_info ? res.data.data.room_info[0].name :
								'';
							switch (res.data.data.status) {
								case 1:
									_this.maintenance_status = '待处理';
									break;
								case 2:
									_this.maintenance_status = '同意';
									break;
								case 3:
									_this.maintenance_status = '拒绝';
									break;
							}
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
			changeStatus(param) {
				if (param == 0) {
					this.leftBgColor = '#FFA100';
					this.leftColor = '#fff';
					this.centerBgColor = '#EEEEEE';
					this.centerColor = '#333333';
					this.rightBgColor = '#EEEEEE';
					this.rightColor = '#333333';
					this.form.status = 1;
				} else if (param == 1) {
					this.leftBgColor = '#EEEEEE';
					this.leftColor = '#333333';
					this.centerBgColor = '#FFA100';
					this.centerColor = '#fff';
					this.rightBgColor = '#EEEEEE';
					this.rightColor = '#333333';
					this.form.status = 2;
				} else {
					this.leftBgColor = '#EEEEEE';
					this.leftColor = '#333333';
					this.centerBgColor = '#EEEEEE';
					this.centerColor = '#333333';
					this.rightBgColor = '#FFA100';
					this.rightColor = '#fff';
					this.form.status = 3;
				}
			},
			repairApply() {
				let base_url = uni.getStorageSync('host');
				console.log(base_url);
				let _this = this;
				request({
					url: base_url + 'teacher/repair/apply',
					method: 'post',
					data: {
						...this.form,
					},
					success(res) {
						if (res.statusCode == 200) {
							console.log(res.data.data);
							_this.$toLink('../maintenance/maintenance', {});
						} else {
							_this.$refs.uToast.show({
								title: res.data.message || '系统错误',
								type: 'warning',
							})
						}

					}
				})
			},
		}
	}
</script>

<style lang="scss">
	.container {
		width: 100%;
		height: 100vh;
		background-color: #F2F2F2;
		overflow: hidden;

		.list {
			width: 100%;
			background: #fff;
			overflow: hidden;
			margin-top: 20rpx;

			.repair_number {
				width: 710rpx;
				margin-left: 20rpx;
				height: 90rpx;
				display: flex;
				justify-content: flex-start;
				background: #fff;
				align-items: center;
				border-bottom: 1rpx solid #F2F2F2;

				text {
					font-size: 30rpx;
					color: #333333;

					&:nth-child(1) {
						width: 150rpx;
					}
				}
			}

			.category {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;

					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.matter {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;

					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.location {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.applicant {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.remarks {
				width: 710rpx;
				margin-left: 20rpx;
				height: 85rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.accessory {
				width: 710rpx;
				margin-left: 20rpx;
				height: 80rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
					}
				}
			}

			.picture {
				width: 710rpx;
				display: flex;
				justify-content: flex-start;
				flex-wrap: wrap;
				margin-left: 20rpx;

				image {
					width: 155rpx;

					&:nth-child(n+1) {
						margin-left: 25rpx;
					}

					&:nth-child(1) {
						margin-left: 0rpx;
					}
				}


			}

			.submit {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					font-size: 26rpx;
					height: 28rpx;
					margin-top: 25rpx;

					&:nth-child(1) {
						color: #666666;
						width: 150rpx;
					}

					&:nth-child(2) {
						color: #333333;
						width: 400rpx;
					}
				}
			}

			.results {
				width: 710rpx;
				margin-left: 20rpx;
				height: 65rpx;
				display: flex;
				justify-content: flex-start;

				text {
					margin-top: 15rpx;

					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
						width: 150rpx;
					}

					&:nth-child(2) {
						background: #ffa100;
						width: 101rpx;
						height: 40rpx;
						text-align: center;
						line-height: 40rpx;
						font-size: 20rpx;
						border-radius: 9rpx;
						color: #fff;
					}

					&:nth-child(3) {
						background: #eeeeee;
						color: #333333;
						font-size: 20rpx;
						width: 101rpx;
						height: 40rpx;
						text-align: center;
						line-height: 40rpx;
						border-radius: 9rpx;
						margin-left: 20rpx;
					}

					&:nth-child(4) {
						width: 101rpx;
						height: 40rpx;
						text-align: center;
						line-height: 40rpx;
						font-size: 20rpx;
						background: #eeeeee;
						color: #333333;
						border-radius: 9rpx;
						margin-left: 20rpx;
					}
				}
			}

			.receiver {
				width: 710rpx;
				margin-left: 20rpx;

				display: flex;
				justify-content: flex-start;
				height: 65rpx;

				text {
					margin-top: 10rpx;

					&:nth-child(1) {
						color: #666666;
						font-size: 26rpx;
					}
				}
			}
		}

		.confirm {
			width: 100%;
			height: 150rpx;
			display: flex;
			justify-content: center;
			align-items: center;

			.verify {
				width: 200rpx;
				height: 60rpx;
				border-radius: 50rpx;
				text-align: center;
				line-height: 60rpx;
				background: linear-gradient(to right, #2C78FE, #32B0FF);
				color: #fff;
				font-size: 30rpx;
			}
		}
	}
</style>
